A finite state machine (FSM) is a presentation of an event-driven (i.e., reactive) system. In an event-driven system, the system makes a transition from one state (also referred to as “mode”) to another, prescribed state, provided that the condition defining a change is true. For example, a FSM may be used to represent a vehicle's automatic transmission. The automatic transmission has a number of operating states, such as park, neutral, drive and reverse. The automatic transmission makes a transition from one state to another when an operator shifts from one position to another, for example, from park to neutral.
Designers often use truth tables to represent relationships among inputs, outputs and states of a FSM. The resulting truth table describes logic necessary to control the behavior of the system under study.
Statechart systems for modeling FSMs permit a user to embed textual definitions of functions in a statechart and invoke those functions in the statechart. In a textually defined function, the procedure performed by the function is defined by code.